package com.itheima.common.utils;
import org.apache.tomcat.util.codec.binary.Base64;

/***
 * @Author： shenkunlin
 * @Description: itheima-leadnews com.itheima.common.util
 * @Date 2021/6/22 : 3:23
 ****/

public class Base64Util {

	//base64 解码
    public static String decode(byte[] bytes) {  
        return new String(Base64.decodeBase64(bytes));
    }  
  
    //base64 编码
    public static String encode(byte[] bytes) {  
        return new String(Base64.encodeBase64(bytes));
    }

	public static void main1(String[] args) {
		String string = "黑马头条";
		//编码
		String encode = encode(string.getBytes());
		System.out.println("编码后：" + encode);
		//解码
		String decode = decode(encode.getBytes());
		System.out.println("解码后：" + decode);
	}

	public static void main(String[] args) {
		String encode = "eyJhbGciOiJIUzUxMiJ9";
		String decode = decode(encode.getBytes());
		System.out.println(decode);
	}


}